<template>
	<view class="main-page" style="align-items: center;">
		<image class="header-bg" src="../../static/mine/bg_header_mine.png"></image>
		<text class="page-title">预约兔</text>
		<view class="info-box" @click="gotoShopInfo">
			<image v-if="userData.headImg" class="avatar" :src="userData.headImg"></image>
			<image v-else class="avatar" src="../../static/mine/ic_default_avatar.png"></image>
			<view class="column-container width-100p">
				<view class="row-container-row-between width-100p">
					<text class="font-333-36 font-weight-600" style="line-height: 50rpx;">{{userData.userName}}</text>
					<image class="wh-24" src="../../static/common/ic_arrow_right.png"></image>
				</view>
				<!-- <text class="font-999-28 mt-6" style="line-height: 40rpx;">营业时间:{{userData.shopStartTime}}-{{userData.shopEndTime}}</text> -->
				<text class="font-999-28 mt-6" style="line-height: 40rpx;">欢迎使用预约兔</text>
			</view>
		</view>
		
		<view class="menu-box" v-if="userData.checkBoss == 0">
			<view class="menu-item" @click="gotoSetBed">
				<image class="wh-80" src="../../static/mine/ic_device_mine.png"></image>
				<text class="font-666-28 mt-14">设备/店员</text>
			</view>
			<view class="menu-item" @click="gotoEmployee">
				<image class="wh-80" src="../../static/mine/ic_employee_mine.png"></image>
				<text class="font-666-28 mt-14">员工账号</text>
			</view>
			<view class="menu-item" @click="gotoServiceItem">
				<image class="wh-80" src="../../static/mine/ic_service_item_mine.png"></image>
				<text class="font-666-28 mt-14">服务项目</text>
			</view>
			<view class="menu-item" @click="gotoAnalysis">
				<image class="wh-80" src="../../static/mine/ic_analysis_mine.png"></image>
				<text class="font-666-28 mt-14">员工绩效</text>
			</view>
		</view>
		
		<view class="row-between-white-box" style="z-index: 100;">
			<view class="row-container">
				<image class="wh-54 mr-15" src="../../static/mine/ic_contact.png"></image>
				<view class="column-container">
					<text class="font-333-32">联系我们</text>
					<text class="font-999-24 mt-4">工作日：早上10:00-晚上18:00</text>
				</view>
			</view>
			<image class="wh-24" src="../../static/common/ic_arrow_right.png"></image>
			
			<button open-type="contact" class="contact-btn"></button>			
		</view>
		
		<view class="row-between-white-box" @click="gotoAdvice" style="z-index: 100;">
			<view class="row-container">
				<image class="wh-54 mr-15" src="../../static/mine/ic_advice.png"></image>
				<text class="font-333-32">意见反馈</text>
			</view>
			<image class="wh-24" src="../../static/common/ic_arrow_right.png"></image>
		</view>
		
		<text class="logout-btn" @click="showLogoutWindow = true">退出登录</text>
		
		<view class="window-main" v-show="showLogoutWindow">
			<view class="reset-window">
				<text class="font-333-36 font-weight-600">确认退出登录？</text>
				<view class="row-container mt-40 width-100p">
					<text class="cancel-btn" @click="showLogoutWindow = false">取消</text>
					<text class="confirm-btn" @click="handleLogout">确定</text>
				</view>
			</view>
		</view>
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				userData:{},
				showLogoutWindow:false
			}
		},
		
		onShow(){
			this.loadUserDetail()
		},
		
		methods: {
			gotoSetBed(){
				uni.navigateTo({
					url:'/pages/mine/setBed'
				})
			},
			
			gotoSwitchShop(){
				uni.navigateTo({
					url:'/pages/mine/switchShop'
				})
			},
			
			gotoShopInfo(){
				uni.navigateTo({
					url:'/pages/mine/shopInfo'
				})
			},
			
			gotoAdvice(){
				uni.navigateTo({
					url:'/pages/mine/advice'
				})
			},
			
			gotoServiceItem(){
				uni.navigateTo({
					url:'/pages/mine/allServiceList'
				})
			},
			
			gotoEmployee(){
				uni.navigateTo({
					url:'/pages/mine/employee'
				})
			},
			
			gotoAnalysis(){
				uni.navigateTo({
					url:'/pages/mine/analysis'
				})
			},
			
			loadUserDetail(){
				let that = this
				this.http({
					url:"/user/userDetail",
					method:"POST",
					hideLoading:true,
					data:{},
					success(data){
						if (data.code == 200){
							that.userData = data.data
							that.cookie.set("ap_user_data" , data.data)
						}
						uni.stopPullDownRefresh()
					},
					failed(e){
						uni.stopPullDownRefresh()
					}
				})
			},
			
			handleLogout(){
				this.showLogoutWindow = false
				uni.setStorageSync("ap_token" , "")
				uni.reLaunch({
					url:'/pages/login/login'
				})
			}
		}
	}
</script>

<style lang="scss">
	.header-bg{
		width: 100%;
		height: 520rpx;
		position: fixed;
		top: 0;
	}
	
	.info-box{
		display: flex;
		flex-direction: row;
		align-items: center;
		width: calc(100% - 60rpx);
		height: 176rpx;
		margin-top: 30rpx;
		z-index: 100;
		
		.avatar{
			width: 116rpx;
			height: 116rpx;
			margin-right: 20rpx;
			flex-shrink: 0;
			border-radius: 67rpx;
		}
		
		.switch-shop-box{
			display: flex;
			flex-direction: row;
			align-items: center;
			justify-content: center;
			border-radius: 4rpx;
			background: #EC5150;
			margin-top: 6rpx;
			width: 136rpx;
			height: 40rpx;
			
			.switch-ic{
				width: 22rpx;
				height: 22rpx;
				margin-right: 10rpx;
			}
		}
	}
	
	.menu-box{
		display: flex;
		flex-direction: row;
		align-items: center;
		justify-content: center;
		width: calc(100% - 90rpx);
		height: 180rpx;
		margin: 20rpx 30rpx 0rpx 30rpx;
		padding: 0rpx 15rpx;
		background: white;
		border-radius: 16rpx;
		z-index: 100;
		
		.menu-item{
			display: flex;
			flex-direction: column;
			align-items: center;
			justify-content: center;
			flex-grow: 1;
			height: 133rpx;
		}
	}
	
	.contact-btn{
		width: 100%;
		height: 100%;
		position: absolute;
		background: transparent;
	}
	
	.logout-btn{
		width: calc(100% - 60rpx);
		height: 88rpx;
		background: #F94C4B;
		border-radius: 16rpx;
		margin: 50rpx 30rpx;
		text-align: center;
		line-height: 88rpx;
		color: white;
		font-size: 32rpx;
		font-weight: 600;
	}
	
	.reset-window{
		display: flex;
		flex-direction: column;
		align-items: center;
		width: calc(100% - 190rpx);
		margin: 0rpx 70rpx;
		padding: 40rpx 25rpx;
		background: white;
		border-radius: 30rpx;
		
		.cancel-btn{
			height: 85rpx;
			flex-grow: 1;
			background: #F5F5F5;
			border-radius: 10rpx;
			margin: 0rpx 15rpx;
			color: #333333;
			font-size: 32rpx;
			text-align: center;
			line-height: 85rpx;
		}
		
		.confirm-btn{
			height: 85rpx;
			flex-grow: 1;
			background: #F94C4B;
			border-radius: 10rpx;
			margin: 0rpx 15rpx;
			color: white;
			font-size: 32rpx;
			text-align: center;
			line-height: 85rpx;
		}
	}
	
	button::after{
		border: none;
	}
	
</style>
